<?php

class ArticleAction extends CommonAction {

    public function _initialize() {

        parent::_initialize();
        $this->assign('identify', 'Article');
    }
    
    public function index() {
        $map = array();
        import("@.ORG.Util.Page");       //导入分页类
        $model = M('Article');
        $keyword = $this->_get('keyword');
        if ($keyword) {
            $where['title'] = array('like', '%' . $keyword . '%');
            //$where['description'] = array('like', '%' . $keyword . '%');
            $where['_logic'] = 'or';
            $map['_complex'] = $where;

            $this->assign('keyword', urldecode($keyword));
        }

        $count = $model->where($map)->count();    //计算总数

        $p = new Page($count, 10);
        $rows = $model
                ->where($map)
                ->limit($p->firstRow . ',' . $p->listRows)
                ->order('article_id desc')
                ->select();
        $page = $p->show();            //分页的导航条的输出变量
        $this->assign("page", $page);
        $this->assign("rows", $rows); //数据循环变量

        $this->display('index');
    }


}